// pages/register/register.js
const util = require('../../utils/util.js')

Page({

  /**
   * 页面的初始数据
   */
	data: {
		studentId: null,
    password: null,
    status:false
	},

	loginTap: function () {
		if(this.data.studentId != null){  
      var app = getApp()
      // console.log("app:" + app.globalData.loginStatus)
      util.login(this.data.studentId, this.data.password,this)
    }
    if (this.data.status == true) {
      util.getUserByStudentId(this.data.studentId,function(userId){
        var theApp = getApp()
        theApp.globalData.userId = userId
        wx.switchTab({
          url: '/pages/discover/discover',
        })
      })
      
    } 
	},  

  registerTap: function (e){
    wx.navigateTo({
      url: '/pages/register/register',
    })
	},

	studentIdInput: function (e) {
		this.setData({
			studentId: e.detail.value
		})
	},

  passwordInput: function(e){
    this.setData({
      password: e.detail.value
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
	onLoad: function (options) {

	},
})